<template>
  <div :style="{ ...styles }" class="position-full overHidden">
    <video v-if="widget.category==='urlPlayer'" :src="state.values.url?state.values.url:null" class="width-100 height-100 videoElement"  loop controls></video>
    <video v-else src="null" class="width-100 height-100 videoElement"  loop controls></video>
  </div>
</template>
<script>
  import {formatColor} from '@/utils';
  import {mapState} from 'vuex';

  export default {
    name: 'UrlPlayer',
    props: {
      widget: {
        type: Object,
        default: () => {
          return {};
        }
      }
    },
    data() {
      return {};
    },
    computed: {
      ...mapState({
        activeTheme: state => state.ide.activeTheme,
      }),
      state() {
        if (!this.widget || !this.widget.UI.state) return;
        return this.widget.getCurrentState();
      },
      styles() {
        const {rect = {}} = this.widget;
        const styles = {};
        const {height: sHeight = 0} = rect;
        sHeight && (styles.lineHeight = `${sHeight}px`);
        return styles;
      },
    },
  };
</script>

<style scoped>
  .overHidden {
    overflow: hidden;
  }

  .inline-block {
    display: inline-block;
    word-break: break-all;
  }

  .videoElement {
    object-fit: fill;
  }
</style>
